/************************************
 * Package: RGcpp					*
 * Authors: Rui Eduardo Gouveia Gil	*
 * Date: 2010						*
 ************************************/
#ifndef __RGCPP_EXCEPTION_H__
#define __RGCPP_EXCEPTION_H__

#include <string>

namespace rgcpp
{

class Exception
{
	private:
		std::string name;
		std::string message;
		std::string stackTrace;
		std::string information;

	public:
		Exception(const std::string& message);
		virtual ~Exception() throw ();

		void printStackTrace();
		std::string getStackTrace();
		void setExceptionInformation(const char* file, const char* function, const int line);

	protected:
		Exception(const std::string& name, const std::string& message);
};

}

#if !defined(__PRETTY_FUNCTION__)
#define __PRETTY_FUNCTION__ __FUNCTION__
#endif

#if !defined(DISABLE_EXCEPTION_PRINT)
#define Throw(x) {rgcpp::Exception exc = x; exc.setExceptionInformation(__FILE__,__PRETTY_FUNCTION__,__LINE__); exc.printStackTrace(); throw exc;}
#else
#define Throw(x) {rgcpp::Exception exc = x; exc.setExceptionInformation(__FILE__,__PRETTY_FUNCTION__,__LINE__); throw exc;}
#endif

#endif
